package com.pagepub.expo.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.opensymphony.xwork2.ActionSupport;
import com.pagepub.core.utils.ExtendString;
import com.pagepub.core.utils.StringUtil;
import com.pagepub.expo.entity.CorpPublication;
import com.pagepub.expo.manager.CorpPublicationMng;

public class ShowBookAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Autowired
	@Qualifier("corpPublicationMng")
	private CorpPublicationMng corpPublicationMng;

	
	public String showbook() throws Exception {

		HttpServletRequest request = ServletActionContext.getRequest();
		String publicationid = ExtendString.nullToSpaceNoTrim(request
				.getParameter("publicationid"));
		boolean checkflag = false;
		if(publicationid!=null && !"".equalsIgnoreCase(publicationid)){
			CorpPublication publication=corpPublicationMng.findById(StringUtil.stringToInt(publicationid));
			if(publication!=null){
				request.setAttribute("publication", publication);// 电子书	
				//request.setAttribute("imgurl", Config.ImageServerURL_CORPPUBIMG);// 电子书图片路径	
				request.setAttribute("imgurl", request.getContextPath()+ "/expo/pub/");// 电子书图片路径	
				request.setAttribute("adid", "01");// 广告ID	
				request.setAttribute("pubtitle",publication.getTitle());// 电子书标题	
				//更新电子书点击率
				checkflag=corpPublicationMng.updatePublicationCount(publication);
				checkflag=true;
			}	
		}	
		if(checkflag){
		   return SUCCESS;
		}else{
			return ERROR;
		}      
      
    }

  

}
